import { handleUrlParams } from "@/utils"
import urlUtils from "@/utils/urlUtils"

export default {
  // 查看活动详情跳转
  viewActivityDetail(details) {
    //配置了自定义页面跳转
    if (details.buttonEvent === "JumpLink") {
      const jumpPath = handleUrlParams(details.jumpLink, {
        studyActivityId: details.studyActivityId,
      })
      try {
        uni.navigateTo({
          url: jumpPath,
        })
      } catch (err) {
        console.log(err, "err")
      }
      try {
        uni.switchTab({
          url: jumpPath,
        })
      } catch (err) {
        console.log(err, "err")
      }
      //跳转到活动详情页面
    } else {
      //判断要跳转的页面是否和当前页面相同避免重复跳转
      const jumpPath = handleUrlParams("/studyRoom/pages/activity/detail", {
        studyActivityId: details.studyActivityId,
      })
      if (jumpPath === urlUtils.getCurrentPageUrl()) {
        return
      }
      uni.navigateTo({ url: handleUrlParams("/studyRoom/pages/activity/detail", { studyActivityId: details.studyActivityId }) })
    }
  },
}
